/***********************************************************************
    filename:   RequestCenter.h
    created:    10/4/2012
    author:     4Ys

    purpose:    Defines base class for Calendar objects
*************************************************************************/
#ifndef _DaterRequestCenter_h_
#define _DaterRequestCenter_h_

#include "DaterSingleton.h"
#include "DaterLinktoSQL.h"

#include <map>
#include <vector>
#include <string>

namespace Dater
{
	/*!
	\brief
		An entity class contains 21 year calendars front and back.
	*/
	class RequestCenter : public Singleton<RequestCenter>
	{
	public:
		/*!
		\brief
			Constructor for RequestCenter class
		*/
		RequestCenter();

		/*!
		\brief
			a function to add the user.
		*/
		void addUser(int uid);
		
		/*!
		\brief
			a function to push the message.
		*/
		void pushRequestCenterMessage(int uid, std::string msg);

		/*!
		\brief
			a function to push the message.
		*/
		void popRequestCenterMessage(int uid);

		/*!
		\brief
			a function to push the message.
		*/
		void clearRequestCenterMessage(int uid);

		/*!
		\brief
			a function to determine whether the queue is empty.
		*/
		bool isRequestCenterMessageEpmty(int uid);

		/*!
		\brief
			a function to push the message.
		*/
		std::string getRequestCenterMessage(int uid);

		//the implement of the stack.
		std::vector<std::string>& getMessageVector(int uid);

	private:
		LinktoSQL linktosql;

		/*!
		 a string which is the charactor to split the order.
		*/
		char _delimiter;

		char _selectResultDelimiter;

		/*!
		 \brief
			 A processing function to split the order.

		 \param order
		     - a string of order from client to server.

		 \param delimiter
		     - a string which is the charactor to split the order.

		 \param splitedVector
		     - a vector of strings which are tiny orders splited from order.

		 \return
			 Nothing.
		*/
		void split(std::string const& order, char delimiter, std::vector<std::string>& splitedVector);

		std::string _user;

		std::string _password;

		std::map<int,std::vector<std::string>> _requestCenterMessage;
	};
}

#endif